<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 准备好容器 -->
    <div id="test">
    </div>
</body>
<!-- 引入依赖 引入的时候，必须就按照这个步骤-->
<script src="../React-js/react.development.js" type = "text/javascript"></script>
<script src = "../React-js/react-dom.development.js" type = "text/javascript"></script>
<script src="../React-js/babel.min.js" type="text/javascript"></script>


<script type="text/babel">
    
    class Demo extends React.Component{
        myRef = React.createRef()
        myRef2 = React.createRef()

        showData = ()=>{
            alert(this.myRef.current.value);
        }

        showData2 = ()=>{
            alert(this.myRef2.current.value);
        }
        showData3 = (event)=>{
            alert(event.target.value);
        }

        render(){
            return(
                <div>
                    <input ref={this.myRef} type = "text" placeholder="点击提示数据"/>&nbsp;
                    <button onClick={this.showData}>点我提示左侧数据</button>&nbsp;
                    <input ref={this.myRef2} onBlur = {this.showData2} type = "text" placeholder="失去焦点提示数据"/>
                    <input  onBlur = {this.showData3} type = "text" placeholder="失去焦点提示数据"/>    
                </div>
            )
        }
    }

    ReactDOM.render(<Demo/>,document.getElementById("test"))
</script>
</html>